﻿using System.Collections.Generic;
using BusTrackerSystem.Model;
using System;
using System.Collections.ObjectModel;

namespace BusTrackerSystem.Repository
{
    public interface IBusTimesRepository
    {
        /// <summary>
        /// Method to begin background scanning of latest times for a given bus stop code
        /// </summary>
        /// <param name="busStopCode">The bus stop code for which to scan</param>
        /// <param name="numberOfBuses">Maximum number of bus times to return</param>
        void BeginScanningLatestTimes(string busStopCode, int numberOfBusTimes);
         
        /// <summary>
        /// Method to halt background scanning of latest times
        /// </summary>
        void StopScanningLatestTimes();

        /// <summary>
        /// A list of bus times which are maintained
        /// </summary>
        List<BusTime> BusTimes { get; }

        /// <summary>
        /// The frequency to scan in seconds - default is 30 seconds
        /// </summary>
        int ScanFrequency { get; set; }

        string ErrorMessage { get; }

        /// <summary>
        /// Event which is fired when the times are updated
        /// </summary>
        event EventHandler LatestTimesUpdated;

        /// <summary>
        /// Event which is fired when an error occurs fetching the times, the string should be the exception method
        /// </summary>
        event EventHandler LatestTimeError;
    }
}
